<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-input v-model="common_code" placeholder="单号" clearable @keyup.enter="getTable"></el-input>
            </div>
        </el-header>
        <el-main class="">
            <el-timeline v-if="tableData">
                <el-timeline-item center placement="top" type="primary" color="">
                    <h2>采购单</h2>
                    <table border="1" style="border-collapse: collapse; width: 100%;" >
                        <thead>
                            <tr style="height:32px;line-height: 32px;background: #e6e6e6;">
                                <th class="table_border">单号</th>
                                <th class="table_border">供应商</th>
                                <th class="table_border">匹数</th>
                                <th class="table_border">总米数</th>
                                <th class="table_border">入库单</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="height:32px;line-height: 32px">
                                <td class="table_border">{{tableData?.purchase?.purchase_code}}</td>
                                <td class="table_border">{{tableData?.purchase?.apply?.apply_name}}</td>
                                <td class="table_border">{{tableData?.purchase?.total_num}}</td>
                                <td class="table_border">0</td>
                                <td class="table_border">
                                    <el-button type="primary" text size="small" @click="show_purchase(tableData?.purchase,1)">查看</el-button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </el-timeline-item>
                <el-timeline-item center placement="top" type="primary" color="">
                    <h2>染色单</h2>
                    <table border="1" style="border-collapse: collapse; width: 100%;" >
                        <thead>
                            <tr style="height:32px;line-height: 32px;background: #e6e6e6;">
                                <th class="table_border">单号</th>
                                <th class="table_border">染色厂</th>
                                <th class="table_border">匹数</th>
                                <th class="table_border">总米数</th>
                                <th class="table_border">入库单</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="height:32px;line-height: 32px">
                                <td class="table_border">{{tableData?.purchase_dye?.purchase_dye_code}}</td>
                                <td class="table_border">{{tableData?.purchase_process?.apply?.apply_name}}</td>
                                <td class="table_border">{{tableData?.purchase_dye?.total_num}}</td>
                                <td class="table_border">0</td>
                                <td class="table_border">
                                    <el-button type="primary" text size="small" @click="show_purchase(tableData?.purchase_dye,2)">查看</el-button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </el-timeline-item>
                <el-timeline-item center placement="top" type="primary" color="">
                    <h2>加工单</h2>
                    <table border="1" style="border-collapse: collapse; width: 100%;" >
                        <thead>
                            <tr style="height:32px;line-height: 32px;background: #e6e6e6;">
                                <th class="table_border">单号</th>
                                <th class="table_border">供应商</th>
                                <th class="table_border">匹数</th>
                                <th class="table_border">总米数</th>
                                <th class="table_border">入库单</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="height:32px;line-height: 32px">
                                <td class="table_border">{{tableData?.purchase_process?.purchase_process_code}}</td>
                                <td class="table_border">{{tableData?.purchase_process?.apply?.apply_name}}</td>
                                <td class="table_border">{{tableData?.purchase_process?.total_num}}</td>
                                <td class="table_border">0</td>
                                <td class="table_border">
                                    <el-button type="primary" text size="small" @click="show_purchase(tableData?.purchase_process,3)">查看</el-button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </el-timeline-item>
            </el-timeline>
        </el-main>
        <!-- <arrival-list v-if="dialog.arrivalrecord" ref="arrivalrecordDialog" @success="handleSuccess" @closed="dialog.arrivalrecord = false" :query="query"></arrival-list> -->
        <select-house v-if="dialog.house" ref="houseDialog" @success="houseBack" @closed="dialog.house = false" :query="query"></select-house><!-- 入库记录 -->
    </el-container>
</template>

<script>
// import ArrivalList from '@/views/business/purchase/arrival/arrivalList.vue'
import SelectHouse from '@/views/business/selectHouse.vue';
export default {
    name: '采购计划管理',
    components: {
        SelectHouse
    },
    data() {
        return {
            common_code: '',
            tableData: null,
            dialog: {
                house: false
            },
            query: {},
        }
    },
    mounted() {
    },
    methods: {
        async getTable(){
            var res = await this.$API.ware.ware.ordernosource.list.get({common_code: this.common_code});
            if(res.code == 1){
                this.tableData = res.data
            }else {
                this.common_code = ''
                this.tableData = null
                this.$message.error("单号不存在")
            }
        },
        show_purchase(row,e){
            if(e == 1) {
                this.query = {input_type: 1, purchase_id: row.id, status: 1}
            }else if(e == 2){
                this.query = {input_type: 2, dye_id: row.id, status: 1}
            }else {
                this.query = {input_type: 3, process_id: row.id, status: 1}
            }
            this.dialog.house = true
            this.$nextTick(() => {
                this.$refs.houseDialog.open('add')
            })
        },
    }
}
</script>

<style lang="scss" scoped>
table{
    text-align: center ;
}
.table_border{
    max-width: 200px;
    height: 32px;
    border: 1px solid #000;
}
</style>
